package com.ssy.lingxi.member.merchant.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;
import com.ssy.lingxi.member.merchant.utils.NumberUtil;

import java.util.Arrays;

/**
 * 会员内部、外部历史记录操作类型枚举
 * @author 万宁
 * @version 2.0.0
 * @date 2020-07-14
 */
public enum MemberValidateHistoryOperationEnum {
    /**
     * 申请注册 - 1
     */
    REGISTER(1, "申请注册"),

    /**
     * 变更资料 - 2
     */
    MODIFY_DETAIL(2, "变更资料"),

    /**
     * 提交平台审核 - 3
     */
    COMMIT_TO_VALIDATE(3, "提交平台审核"),

    /**
     * 平台审核 - 4
     */
    PLATFORM_VALIDATE(4, "审核会员"),

    /**
     * 创建下级会员 - 5
     */
    CREATE_SUB_MEMBER(5, "代录入"),

    /**
     * 申请成为下级会员 - 6
     */
    APPLY_FOR_SUB_MEMBER(6, "申请会员入库"),

    /**
     * 修改入库资料后，申请会员变更
     */
    MODIFY_DEPOSIT_DETAIL(7, "申请会员变更"),

    /**
     * 冻结会员 - 8
     */
    FREEZE_MEMBER(8, "冻结会员"),

    /**
     * 解冻会员 - 9
     */
    UNFREEZE_MEMBER(9, "解冻会员"),

    /**
     * 解除关系 - 10
     */
    ELIMINATE_MEMBER(10, "解除关系"),

    /**
     * 黑名单 - 11
     */
    BLACK_LIST(11, "黑名单会员"),

    /**
     * 修改注册资料 - 12
     */
    MODIFY_REGISTER_DETAILS(12, "修改注册资料"),

    TO_SUBMIT_EVALUATE_RESULT(13, "待提交汇总考评结果"),

    PUBLISH_EVALUATE(14, "发布考评表"),

    SEND_MODIFY_NOTICE(15, "发送整改通知"),

    CHANGE_VALIDATE_NOT_PASS(16, "会员变更审核不通过"),

    CHANGE_VALIDATE_NOT_PASS_LEVEL_TWO(17, "会员变更审核不通过(二级)"),

    CHANGE_VALIDATE_NOT_PASS_LEVEL_ONE(18, "会员变更审核不通过(一级)"),

    CHANGE_VALIDATE_PASS(19, "会员变更审核通过"),

    CONFIRM_RECTIFICATION_RESULT(20, "确认整改结果"),

    CLASSIFICATION(21, "入库分类"),

    CLASSIFY_NOT_PASS(22,"入库分类不通过"),

    OBSERVE(23, "入库考察"),

    OBSERVE_NOT_PASS(24, "入库考察不通过"),

    DEPOSIT_NOT_PASS_LEVEL_TWO(25, "入库审核不通过(二级)"),

    DEPOSIT_NOT_PASS_LEVEL_ONE(26, "入库审核不通过(一级)"),

    DEPOSIT_DATA_NOT_PASS(27, "入库资料审核不通过"),

    VALIDATE_NOT_PASS(28, "审核不通过"),

    VALIDATE_LEVEL_TWO(29, "审核会员(二级)"),

    VALIDATE_LEVEL_ONE(30,  "审核会员(一级)"),

    CHANGE(31, "审核会员变更"),

    CHANGE_LEVEL_TWO(32, "审核会员变更(二级)"),

    CHANGE_LEVEL_ONE(33, "审核会员变更(一级)"),

    VALIDATE_MEMBER_NOT_PASS(34, "审核会员不通过"),

    VALIDATE_MEMBER_NOT_PASS_LEVEL_TWO(35, "审核会员不通过(二级)"),

    VALIDATE_MEMBER_NOT_PASS_LEVEL_ONE(36, "审核会员不通过(一级)"),

    VALIDATE_MEMBER_PASS(37, "审核会员通过"),

    VALIDATE_RECTIFICATION(38, "审核考评结果"),

    DEPOSIT(39, "审核入库"),

    DEPOSIT_LEVEL_TWO(40, "审核入库(二级)"),

    DEPOSIT_LEVEL_ONE(41, "审核入库(一级)"),

    DEPOSIT_DATA(42, "审核入库资料"),

    DEPOSIT_CLASSIFICATION(43, "审核入库资质"),

    VALIDATE_PASS(44, "审核通过"),

    DATA_DEPOSIT(45, "审核资料入库"),

    SUBMIT_SUMMARY(46, "提交汇总考评结果"),

    SUBMIT_NOT_PASS(47, "提交审核不通过"),

    SUBMIT_VALIDATE(48, "提交审核会员"),

    SUBMIT_RECTIFICATION(49, "提交整改"),

    BULLETIN(50, "通报考评结果"),

    DEPOSIT_NOT_PASS(51, "入库审核不通过"),

    DEPOSIT_QUALIFICATION_NOT_PASS(52, "入库资质审核不通过"),

    APPLY_FOR_MEMBER(53, "申请成为会员"),

    /**
     * 未知 - 99
     */
    UNKNOWN(99, "未知");

    private final Integer code;

    MemberValidateHistoryOperationEnum(Integer code, String msg) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return LanguageHolder.getName(this.getClass(), this.getCode());
    }

    public static String getMsgByCode(Integer code) {
        return LanguageHolder.getName(MemberValidateHistoryOperationEnum.class, code);
    }

    public static MemberValidateHistoryOperationEnum parseString(String code) {
        Integer index = NumberUtil.tryParseInteger(code);
        if(index.equals(0)) {
            return UNKNOWN;
        }

        return Arrays.stream(MemberValidateHistoryOperationEnum.values()).filter(e -> e.getCode().equals(index)).findFirst().orElse(UNKNOWN);
    }
}
